<?php

namespace App\Models\news;

use App\Models\BaseModel;
use Carbon\Carbon;

class NewsListModel extends BaseModel
{
    protected $table = 'news_list';
    protected $primaryKey = 'id';

    public function getSendTimeAttribute($value)
    {
        return $value ? Carbon::createFromTimestamp($value)->format('Y-m-d') : '';
    }


    public function setSendTimeAttribute($value)
    {
        $this->attributes['activity_time'] = $value ? strtotime($value) : '';
    }


    public function getNewsTemplate()
    {
        return $this->hasOne(NewsTemplateModel::class, 'id', 'news_id');
    }


}
